/*
 *  Cero Project - Copyright   2006 The Cero Developement Team 
 *  (Michael Laguerre, Camille Roux, Matthieu Segret, Mathieu Sivade) 
 * 
 *  This program is free software; you can redistribute it and/or modify it 
 *  under the terms of the GNU General Public License as published by the Free 
 *  Software Foundation; either version 2 of the License, or (at your option) 
 *  any later version.
 * 
 *  This program is distributed in the hope that it will be useful, but 
 *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
 *  for more details.
 */

package org.ceroproject.ui.graphical.tools.base;

import java.awt.event.KeyEvent;

import org.ceroproject.ui.graphical.tools.Deck;
import org.ceroproject.ui.graphical.tools.GraphicsCard;
import org.ceroproject.ui.graphical.tools.GraphicsZone;
import org.ceroproject.ui.graphical.tools.UserInputListener;


/**
 * Class which select a Graphics Zone
 * 
 * @author matt
 */
public class ZoneSelecter implements UserInputListener {

	/* -------------- field ------------- */

	/** Former selected zone */
	private GraphicsZone gZone;

	/* ----------- Constructor ---------- */

	/**
	 * Constructor for objects of class ZoneSelecter
	 */
	public ZoneSelecter() {
	}

	/* ------------- Method ------------- */

	/**
	 * Select a graphical Card Invoked when card has been clicked
	 * 
	 * @param selectedGCard
	 *            selected graphical Card
	 */
	public void onSelectedCardChanged(GraphicsCard selectedGCard) {
	}

	/**
	 * Select a graphical Zone Invoked when the zone has been clicked
	 * 
	 * @param selectedGZone
	 *            selected graphical Zone
	 */
	public void onZoneSelected(GraphicsZone selectedGZone) {
		// unselected the older selected zone
		if (gZone != null)
			gZone.setSelected(false);

		// selected the new selected zone
		if (selectedGZone != null)
			selectedGZone.setSelected(true);

		gZone = selectedGZone;
	}

	/**
	 * Invoked when a key has been pressed.
	 * 
	 * @param deck
	 *            which is a graphical appearance of the game's deck
	 */
	public void onKeyPressed(KeyEvent e, Deck deck) {
		deck.repaint();
	}
}
